package com.sitia.jd.util;

import com.sitia.common.core.domain.entity.SysRole;
import com.sitia.common.utils.SecurityUtils;

import java.util.List;

/**
 * 当前登陆用户根据类
 */
public class LoginUserUtil {
    /**
     * 判断当前登陆用户是否是免息券客户
     * @return
     */
    public static boolean isMxUser(){
        List<SysRole> roles = SecurityUtils.getLoginUser().getUser().getRoles();
        boolean containsMxUserRole = roles.stream()
                .anyMatch(role -> role.getRoleKey().equals("MX_USER"));
        return containsMxUserRole;
    }
    /**
     * 判断当前登陆用户是否是商家
     * @return
     */
    public static boolean isBusiness(){
        List<SysRole> roles = SecurityUtils.getLoginUser().getUser().getRoles();
        boolean containsBusiness = roles.stream()
                .anyMatch(role -> role.getRoleKey().equals("business"));
        return containsBusiness;
    }

    /**
     * 判断当前登陆用户是否是系统管理员
     * @return
     */
    public static boolean isSysAdmin(){
        List<SysRole> roles = SecurityUtils.getLoginUser().getUser().getRoles();
        boolean containsBusiness = roles.stream()
                .anyMatch(role -> role.getRoleKey().equals("sys_admin"));
        return containsBusiness;
    }
}
